cmake_minimum_required(VERSION 3.31)
project(OpenGL_Demo)

set(CMAKE_CXX_STANDARD 20)

# 设置 Release 模式下使用 /MT
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")

# 设置 Debug 模式下使用 /MTd
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

set(CMAKE_TOOLCHAIN_FILE "D:/Jetbrains/vcpkg-clion/scripts/buildsystems/vcpkg.cmake")

include_directories("./include")

#link_directories("./lib")

file(GLOB_RECURSE src_dir
        "./src/*.h"
        "./src/*.c"
        "./src/*.cpp"
        "main.cpp"
)

add_executable(${PROJECT_NAME}
        ${src_dir}
)

find_package(glfw3 REQUIRED)
find_package(Assimp REQUIRED)
find_package(OpenEXR REQUIRED)

target_include_directories(${PROJECT_NAME}
        PRIVATE ${OPENEXR_INCLUDE_DIRS}
        PRIVATE ${ASSIMP_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME}
        PRIVATE OpenEXR::OpenEXR
        PRIVATE ${ASSIMP_LIBRARIES}
        glfw
        opengl32
        glu32
)

# 添加自定义命令，在构建目标时复制文件夹
set(RESOURCE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/resources")
set(RESOURCE_TARGET_DIR "${PROJECT_BINARY_DIR}/resources")
add_custom_command(
        TARGET ${PROJECT_NAME} PRE_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${RESOURCE_SOURCE_DIR} ${RESOURCE_TARGET_DIR}
        COMMENT "Copying resources to output directory"
)
